# Contributor: Mike Crute <mike@crute.us>
# Maintainer: Mike Crute <mike@crute.us>
pkgname=nmon
pkgver=16q
pkgrel=0
pkgdesc="Nigel's performance Monitor for Linux"
url="https://nmon.sourceforge.net/"
arch="all"
license="BSD-3-Clause"
options="!check" # no upstream tests
makedepends="ncurses-dev"
source="
	glibc.patch

	https://sourceforge.net/projects/nmon/files/lmon$pkgver.c
	"

prepare() {
	mkdir "$builddir"
	cp lmon$pkgver.c "$builddir"/lmon.c
	default_prepare
}

build() {
	case "$CARCH" in
		ppc64le)		_BUILD_ARCH="POWER" ;;
		s390x)			_BUILD_ARCH="MAINFRAME" ;;
		arm*|aarch64)	_BUILD_ARCH="ARM" ;;
		*)				_BUILD_ARCH="X86" ;;
	esac

	echo "Building for $_BUILD_ARCH"
	cc -o nmon lmon.c -g -O3 -Wall -lncurses -lm \
		-D $_BUILD_ARCH -D JFS -D GETUSER -D LARGEMEM
}

package() {
	install -Dm0755 nmon "$pkgdir"/usr/bin/nmon
}

sha512sums="
c6749baeeefbb5fa781badcf0a3b1a77792498663155b70f00ae8da751eb72ac38f1f734fd9e2eb32cb364938e366453f50e29928f247b945b684021fbde9af5  glibc.patch
06386a4c4b77d029b7cbbbc7f4f8b22028787d286e725257b5daef6d77551c5d3d2c26d303adfab8a953455e51ae308ffb5b1170856ff7b391e696f677bafeef  lmon16q.c
"
